﻿using UnityEngine;
using KingSley;

/// <summary>
/// 修改角色状态机情况
/// </summary>
public class PlayerAnimatorController : MonoSingleton<PlayerAnimatorController>
{
    public Animator AnimatorPlayer;

    /// <summary>
    /// 死亡状态机
    /// </summary>
    public void PlayerDeath()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Death;
        AnimatorPlayer.SetBool(PlayerState.Instance().IdleBool, false);
        AnimatorPlayer.SetBool(PlayerState.Instance().RunBool, false);
        AnimatorPlayer.SetTrigger(PlayerState.Instance().DeathTrigger);
    }

    /// <summary>
    /// 静止状态机
    /// </summary>
    public void PlayerIdle()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Idle;
        AnimatorPlayer.SetBool(PlayerState.Instance().IdleBool, true);
        AnimatorPlayer.SetBool(PlayerState.Instance().WalkBool, false);
        AnimatorPlayer.SetBool(PlayerState.Instance().RunBool, false);
    }

    /// <summary>
    /// 行走状态机
    /// </summary>
    public void PlayerWalk()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Walk;
        AnimatorPlayer.SetBool(PlayerState.Instance().IdleBool, false);
        AnimatorPlayer.SetBool(PlayerState.Instance().WalkBool, true);
        AnimatorPlayer.SetBool(PlayerState.Instance().RunBool, false);
    }

    /// <summary>
    /// 跑步状态机
    /// </summary>
    public void PlayerRun()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Run;
        AnimatorPlayer.SetBool(PlayerState.Instance().IdleBool, false);
        AnimatorPlayer.SetBool(PlayerState.Instance().WalkBool, false);
        AnimatorPlayer.SetBool(PlayerState.Instance().RunBool, true);
    }

    /// <summary>
    /// 翻滚状态机
    /// </summary>
    public void PlayerGun()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Gun;
        AnimatorPlayer.SetTrigger(PlayerState.Instance().GunTrigger);
        AnimatorPlayer.SetBool(PlayerState.Instance().IdleBool, true);
        AnimatorPlayer.SetBool(PlayerState.Instance().WalkBool, false);
        AnimatorPlayer.SetBool(PlayerState.Instance().RunBool, false);
    }

    /// <summary>
    /// 受伤状态机
    /// </summary>
    public void PlayerHit()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Hit;
        AnimatorPlayer.SetTrigger(PlayerState.Instance().HitTrigger);
        AnimatorPlayer.SetBool(PlayerState.Instance().IdleBool, true);
        AnimatorPlayer.SetBool(PlayerState.Instance().WalkBool, false);
        AnimatorPlayer.SetBool(PlayerState.Instance().RunBool, false);
    }

    /// <summary>
    /// 攻击1普通攻击状态机
    /// </summary>
    public void PlayerAttack1()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Attack1;
        AnimatorPlayer.SetInteger(PlayerState.Instance().AttackInt, 1);
    }

    /// <summary>
    /// 攻击2范围旋转攻击状态机
    /// </summary>
    public void PlayerAttack2()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Attack2;
        AnimatorPlayer.SetInteger(PlayerState.Instance().AttackInt, 2);
    }

    /// <summary>
    /// 攻击3连续范围攻击状态机
    /// </summary>
    public void PlayerAttack3()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Attack3;
        AnimatorPlayer.SetInteger(PlayerState.Instance().AttackInt, 3);
    }

    /// <summary>
    /// 攻击4强力攻击状态机
    /// </summary>
    public void PlayerAttack4()
    {
        PlayerState.Instance().PlayerStateNow = PlayerStateEnum.Attack4;
        AnimatorPlayer.SetInteger(PlayerState.Instance().AttackInt, 4);
    }

    /// <summary>
    /// 结束攻击
    /// </summary>
    public void PlayerAttackEnd()
    {
        AnimatorPlayer.SetInteger(PlayerState.Instance().AttackInt, -1);
    }
}
